#ifndef RESDIFF_H
#define RESDIFF_H

#include <QMutex>
#include <QObject>
#include <opencv2/core/mat.hpp>
#include "rknn_api.h"


class resDiff : public QObject
{
    Q_OBJECT
public:
    resDiff();

    bool loadModel();
    int setembedding(cv::Mat baseimg);

    cv::Mat outImage_;
    // float pred_score_;
    // qint64 elapsed;
    // float scale_;

    int isInit = 0;
    const QString modelPath = "master/models/resdiff/RESdifference.rknn";
    const QString extractPath = "master/models/resdiff/RESextract.rknn";

    cv::Mat detect(cv::Mat &Image, float &pred_score_, qint64 &elapsed, float &scale_);
    bool unloadModel();
private:
    QMutex resDiffRknn;
    rknn_context ctx = 0;
    rknn_input_output_num ioNum;
    int modelDataSize;
    rknn_sdk_version version;
    unsigned char *modelData;
    int modelExtracDataSize;
     unsigned char *modelExtracData;
    int input_num ;
    rknn_tensor_mem *input_mems[2];
    rknn_tensor_mem *output_mems[2];
    rknn_tensor_attr inputAttrs[2];
    rknn_tensor_attr outputAttrs[2];
    int input_size = 224;
    cv::Mat image;


};

#endif // RESDIFF_H
